package controle.aplicativo.apresentacao.controle;

import java.io.FileNotFoundException;
import java.io.InputStream;

import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;

import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
 
@Controller
@Scope("request")
public class DownloadPortifolioBean { 
	
	private StreamedContent arquivo;    
    
    public DownloadPortifolioBean() throws FileNotFoundException {    
        InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/arquivos/portifolio.pdf");    
        arquivo = new DefaultStreamedContent(stream, "application/pdf", "portifolio.pdf");    
    }    
    
    public StreamedContent getArquivo() {    
        return arquivo;    
    }    
    
    public void setArquivo(StreamedContent arquivo) {    
        this.arquivo = arquivo;    
    }    
}  